package com.bondex.charter.service;

import com.bondex.charter.maindata.pojo.api.BaseComPackageVO;
import com.bondex.charter.maindata.pojo.api.BaseSeaDeliveryMethodVO;
import com.bondex.charter.maindata.pojo.api.BaseSeaFreightClauseVO;
import com.bondex.charter.maindata.pojo.api.BaseSeaPortVO;
import com.bondex.charter.maindata.service.MainDataService;
import com.bondex.global.pojo.JsonDataT;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 主数据查询服务类
 * @author zxl
 * 20210916
 */
@Service
public class BasicDataService extends BaseService {
    private Logger logger = LoggerFactory.getLogger(BasicDataService.class);
    @Resource
    private MainDataService mainDataService;

    /**
     * 港口主数据查询
     * @param sToken
     * @param sLikeStr
     * @return
     */
    public JsonDataT<List<BaseSeaPortVO>> getSeaPortForAutocomplete(String sToken, String sLikeStr) {
        JsonDataT<List<BaseSeaPortVO>> listJsonDataT = new JsonDataT<>();
        try {
            listJsonDataT = mainDataService.getSeaPortForAutocomplete(sToken, sLikeStr);
        } catch (Exception e) {
            listJsonDataT.setSuccess(Boolean.FALSE);
            listJsonDataT.setMsg("查询港口主数据接口失败：" + e.getMessage());
            logger.error("查询港口主数据接口失败：" + e.getMessage());
        }
        return listJsonDataT;
    }

    /**
     * 包装方式主数据
     * @param sToken
     * @param sLikeStr
     * @return
     */
    public JsonDataT<List<BaseComPackageVO>> getComPackageForAutocomplete(String sToken, String sLikeStr) {
        JsonDataT<List<BaseComPackageVO>> listJsonDataT = new JsonDataT<>();
        try {
            listJsonDataT = mainDataService.getComPackageForAutocomplete(sToken, sLikeStr);
        } catch (Exception e) {
            listJsonDataT.setSuccess(Boolean.FALSE);
            listJsonDataT.setMsg("查询包装方式主数据接口失败：" + e.getMessage());
            logger.error("查询包装方式主数据接口失败：" + e.getMessage());

        }
        return listJsonDataT;
    }

    /**
     * 运费条款主数据
     * @param sToken
     * @param sLikeStr
     * @return
     */
    public JsonDataT<List<BaseSeaDeliveryMethodVO>> getSeaDeliveryMethodForAutocomplete(String sToken, String sLikeStr) {
        JsonDataT<List<BaseSeaDeliveryMethodVO>> listJsonDataT = new JsonDataT<>();
        try {
            listJsonDataT = mainDataService.getSeaDeliveryMethodForAutocomplete(sToken, sLikeStr);
        } catch (Exception e) {
            listJsonDataT.setSuccess(Boolean.FALSE);
            listJsonDataT.setMsg("查询运费条款主数据接口失败：" + e.getMessage());
            logger.error("查询运费条款主数据接口失败：" + e.getMessage());
        }
        return listJsonDataT;
    }

    /**
     * 付款方式主数据
     * @param sToken
     * @param sLikeStr
     * @return
     */
    public JsonDataT<List<BaseSeaFreightClauseVO>> getSeaFreightClauseForAutocomplete(String sToken, String sLikeStr) {
        JsonDataT<List<BaseSeaFreightClauseVO>> listJsonDataT = new JsonDataT<>();
        try {
            listJsonDataT = mainDataService.getSeaFreightClauseForAutocomplete(sToken, sLikeStr);
        } catch (Exception e) {
            listJsonDataT.setSuccess(Boolean.FALSE);
            listJsonDataT.setMsg("查询付款方式数据接口失败：" + e.getMessage());
            logger.error("查询付款方式数据接口失败：" + e.getMessage());

        }
        return listJsonDataT;
    }

}
